home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows1 / commdem2.zip / COMMDEMO.GLB < prev    next >
Text File  |  1992-02-03  |  5KB  |  116 lines

  1. DefInt A-Z
  2.  
  3. 'Device Control Block (DCB) type structure used by the
  4. 'Windows API functions GetCommState and SetCommState
  5. '
  6. Type DCB_Type
  7.     Id          As String * 1   ' Port Id from OpenComm
  8.     BaudRate    As Integer      ' Baud Rate
  9.     ByteSize    As String * 1   ' Data Bit Size (4 to 8)
  10.     Parity      As String * 1   ' Parity
  11.     StopBits    As String * 1   ' Stop Bits
  12.     RlsTimeOut  As Integer      ' Carrier Detect Time "CD"
  13.     CtsTimeOut  As Integer      ' Clear-to-Send Time
  14.     DsrTimeOut  As Integer      ' Data-Set-Ready Time
  15.     ModeControl As Integer      ' Mode Control Bit Fields
  16.     XonChar     As String * 1   ' XON character
  17.     XoffChar    As String * 1   ' XOFF character
  18.     XonLim      As Integer      ' Min characters in buffer before XON is sent
  19.     XoffLim     As Integer      ' Max characters in buffer before XOFF is send
  20.     peChar      As String * 1   ' Parity Error Character
  21.     EofChar     As String * 1   ' EOF/EOD character
  22.     EvtChar     As String * 1   ' Event character
  23.     TxDelay     As Integer      ' Reserved/Not Used
  24. End Type
  25. '
  26. 'Type structure used by the GetCommError API function
  27. '
  28. Type COMSTAT_Type
  29.     ModeControl As String * 1
  30.     cbInQue As Integer
  31.     cbOutQue As Integer
  32. End Type
  33. '
  34. 'Windows COM related API function declarations
  35. '
  36. Declare Function OpenComm Lib "USER" (ByVal lpCommName As Any, ByVal wInQueue, ByVal wOutQueue)
  37. Declare Function CloseComm Lib "USER" (ByVal nCid)
  38. Declare Function ReadComm Lib "USER" (ByVal nCid, ByVal lpBuf As Any, ByVal nSize)
  39. Declare Function WriteComm Lib "USER" (ByVal nCid, ByVal lpBuf As Any, ByVal nSize)
  40. Declare Function BuildCommDCB Lib "USER" (ByVal lpDef As Any, lpDCB As DCB_Type)
  41. Declare Function GetCommState Lib "USER" (ByVal nCid, DCB As DCB_Type)
  42. Declare Function SetCommState Lib "USER" (DCB As DCB_Type)
  43. Declare Function SetCommEventMask Lib "USER" (ByVal nCid, ByVal nEvtMask) As Long
  44. Declare Function GetCommEventMask Lib "USER" (ByVal nCid, ByVal nEvtMask)
  45. Declare Function GetCommError Lib "USER" (ByVal nCid, COMSTAT As COMSTAT_Type)
  46. Declare Function FlushComm Lib "USER" (ByVal nCid, ByVal nQueue)
  47. '
  48. 'Possible return values (error codes) from the Windows API function OpenComm
  49. '
  50. Global Const IE_BADID = -1      ' Invalid or unsupported id
  51. Global Const IE_OPEN = -2       ' Device Already Open
  52. Global Const IE_NOPEN = -3      ' Device Not Open
  53. Global Const IE_MEMORY = -4     ' Unable to allocate queues
  54. Global Const IE_DEFAULT = -5    ' Error in default parameters
  55. Global Const IE_HARDWARE = -10  ' Hardware Not Present
  56. Global Const IE_BYTESIZE = -11  ' Illegal Byte Size
  57. Global Const IE_BAUDRATE = -12  ' Unsupported BaudRate
  58. '
  59. 'Possible return values from the Windows API function GetCommError
  60. '
  61. Global Const CE_BREAK = &H10
  62. Global Const CE_CTSTO = &H20
  63. Global Const CE_DNS = &H800
  64. Global Const CE_DSRTO = &H40
  65. Global Const CE_FRAME = &H8
  66. Global Const CE_IOE = &H400
  67. Global Const CE_MODE = &H8000
  68. Global Const CE_OOP = &H1000
  69. Global Const CE_OVERRUN = &H2
  70. Global Const CE_PTO = &H200
  71. Global Const CE_RLSDTO = &H80
  72. Global Const CE_RXOVER = &H1
  73. Global Const CE_RXPARITY = &H4
  74. Global Const CE_TXFULL = &H100
  75. '
  76. 'Possible communications events used with the API functions GetCommEventMask and SetCommEventMask
  77. '
  78. Global Const EV_RXCHAR = &H1    'Set when a character is received and placed in the input buffer
  79. Global Const EV_RXFLAG = &H2    'Set when the event character is received and placed in the input buffer
  80. Global Const EV_TXEMPTY = &H4   'Set when the last character in the transmit queue is sent
  81. Global Const EV_CTS = &H8       'Set when the clear-to-send (CTS) signal changes state
  82. Global Const EV_DSR = &H10      'Set when the data-set-ready (DSR) signal changes state
  83. Global Const EV_RLSD = &H20     'Set when the receive-line-signal-detect (RLSD or CD) signal changes state
  84. Global Const EV_BREAK = &H40    'Set when a break is deteced on input
  85. Global Const EV_ERR = &H80      'Set when a line-status error (CE_FRAME, CE_OVERRUN, CE_RXPARITY) occurs
  86. Global Const EV_RING = &H100    'Set when a ring indicator is detected
  87. Global Const EV_PERR = &H200    'Set when a printer error is detected (CE_DNS, CE_IOE, CE_LOOP, CE_PTO)
  88. Global Const EV_ALL = &H3FF     'Value when all of the above event masks are set
  89. '
  90. 'Possible parity settings for the Parity field in the DCB_Type type structure
  91. '
  92. Global Const NOPARITY = 0
  93. Global Const ODDPARITY = 1
  94. Global Const EVENPARITY = 2
  95. '
  96. 'Possible stop bit settings for the StopBits field in the DCB_Type type structure
  97. '
  98. Global Const ONESTOPBIT = 0
  99. Global Const ONE5STOPBITS = 1   '1.5 STOP BITS
  100. Global Const TWOSTOPBITS = 2
  101. '
  102. 'Boolean constants
  103. '
  104. Global Const False = 0
  105. Global Const True = Not False
  106. '
  107. 'Default message box caption
  108. '
  109. Global Const DefMsgCaption = "Communications Demo"
  110. '
  111. 'Variables representing carriage return and carriage return linefeed respectively
  112. '
  113. Global CR As String
  114. Global CRLF As String
  115.  
  116.